<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">


    <p:growl autoUpdate="true"/>
    <h:outputLabel style="font-size: x-small" value="(*) Campo obligatorio"/>
    <br/>
    <br/>
    <h:panelGrid columns="4" id="idfacturapanel">
        <p:outputLabel value="Alumno" for="idfactalumno"/>
        <p:outputPanel>
            <p:remoteCommand id="resetInput" name="resetInput" action="#{alumnoController.fac.resetInput}"
                             update="@this" process="@this"/>
            <p:inputText id="idfactalumno" value="#{alumnoController.fac.searchParamAlumno}"
                         onchange="resetInputText()"
                         required="true" requiredMessage='El campo "Alumno" es requerido'>
                <p:ajax/>
            </p:inputText>

            <p:commandButton update=":formalumno:idtablelistalumno :formalumno:dialog" process="@this idfactalumno"
                             icon="search" actionListener="#{alumnoController.fac.buscarListaAlumno()}" immediate="true"/>
        </p:outputPanel>

        <p:outputLabel value="Fecha" for="idfechafactura"/>
        <p:outputPanel>
            <p:calendar readonlyInput="true" mode="popup" navigator="true" showButtonPanel="true"
                        showOn="button" required="true" requiredMessage='El campo "Fecha" es requerido'
                        id="idfechafactura" value="#{alumnoController.fac.facalumno.fechafactura}"/>
            <p:watermark for="idfechafactura" value="dd/mm/aa" />
        </p:outputPanel>

        <p:outputLabel value="Importe" for="idfactimporte"/>
        <p:inputMask maxlength="250" placeHolder="" mask="9?9999999999999999999999999999999"
                     id="idfactimporte" required="true"
                     requiredMessage='El campo "Importe" es requerido'
                     value="#{alumnoController.fac.facalumno.importe}"/>
        <p:outputLabel value="Servicio" for="idfactservicio"/>
        <p:selectOneMenu style="width: 180px" id="idfactservicio" required="true"
                         requiredMessage='El campo "Servicio" es requerido'
                         value="#{alumnoController.fac.facalumno.servicio}" >
            <f:selectItem itemValue="AM" itemLabel="AM"/>
            <f:selectItem itemValue="A" itemLabel="A"/>
            <f:selectItem itemValue="A1" itemLabel="A1"/>
            <f:selectItem itemValue="A2" itemLabel="A2"/>
            <f:selectItem itemValue="B" itemLabel="B"/>
            <f:selectItem itemValue="BTP" itemLabel="BTP"/>
            <f:selectItem itemValue="C" itemLabel="C"/>
            <f:selectItem itemValue="C+E" itemLabel="C+E"/>
            <f:selectItem itemValue="D" itemLabel="D"/>
            <f:selectItem itemValue="E" itemLabel="E"/>
            <f:selectItem itemValue="1 Practica" itemLabel="1 Practica"/>
            <f:selectItem itemValue="5 Practicas" itemLabel="5 Practicas"/>
            <f:selectItem itemValue="10 Practicas" itemLabel="10 Practicas"/>
            <f:selectItem itemValue="Derecho a Examen" itemLabel="Derecho a Examen"/>
            <f:selectItem itemValue="Renovar Matricula" itemLabel="Renovar Matricula"/>
        </p:selectOneMenu >
        <p:commandButton value="Guardar"
                         process="@this idfactalumno idfechafactura idfactimporte idfactservicio"
                         update=":formalumno:tabView:tabpermisos :formalumno:tabView:idfacturapanel :formalumno:tabView:idtablafacturaalumno"
                         actionListener='#{alumnoController.saveFacturarAlumno}'
                         oncomplete="printFactura(args);"/>
        <p:commandButton value="Cancelar" process="@this" actionListener="#{alumnoController.fac.init()}"/>
    </h:panelGrid>

    <script type="text/javascript">
        function resetInputText() {
            var item = document.getElementById("formalumno:tabView:idfactalumno");
            var value = item.value;
            if (value.length === 0) {
                resetInput();
            }
        }
    </script>
</ui:composition>